<template>
  <Article :form="form" @handleClick="handleClick" />
</template>

<script>
import { createArticle } from '@/api/article'
import Article from '@/views/article/components/article'

export default {
  name: 'ArticlePublish',
  components: { Article },
  data() {
    return {
      form: {
        title: '',
        cover_url: '',
        content: '',
        quote: '',
        category_id: null,
        tag_id_list: [],
        is_public: true,
        recommended: true
      }
    }
  },
  created() {
  },
  methods: {
    handlePublish(form) {
      createArticle(form).then(() => {
        this.$message({
          message: '发布成功',
          type: 'success'
        })
        this.form = {}
      })
      this.$router.push({ name: 'ArticleList' })
    },
    handleClick(form) {
      this.handlePublish(form)
    }
  }
}
</script>

<style scoped>

</style>
